Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`HRDScreen Component renders correctly when enterprise domain is undefined 1`] = `
<div
data-__type="hrd_pane"
data-header={
<p>
Login with your corporate credentials. []
</p>
}
data-i18n={
{
"str": [Function],
}
}
data-model={
Immutable.Map {
"id": "__lock-id__",
"i18n": Immutable.Map {
"strings": Immutable.Map {
"enterpriseLoginIntructions": "Login with your corporate credentials.",
"enterpriseActiveLoginInstructions": "Please enter your corporate credentials at %s.",
},
},
}
}
data-passwordInputPlaceholder=" []"
data-usernameInputPlaceholder=" []"
/>
`;

exports[`HRDScreen Component renders correctly when there is an enterprise domain 1`] = `
<div
data-__type="hrd_pane"
Expand Down Expand Up @@ -57,3 +86,61 @@ exports[`HRDScreen Component renders correctly when there is no enterprise domai
data-usernameInputPlaceholder=" []"
/>
`;

exports[`HRDScreen Component uses fallback message when enterprise domain is empty string 1`] = `
<div
data-__type="hrd_pane"
data-header={
<p>
Login with your corporate credentials. []
</p>
}
data-i18n={
{
"str": [Function],
}
}
data-model={
Immutable.Map {
"id": "__lock-id__",
"i18n": Immutable.Map {
"strings": Immutable.Map {
"enterpriseLoginIntructions": "Login with your corporate credentials.",
"enterpriseActiveLoginInstructions": "Please enter your corporate credentials at %s.",
},
},
}
}
data-passwordInputPlaceholder=" []"
data-usernameInputPlaceholder=" []"
/>
`;

exports[`HRDScreen Component uses fallback message when enterprise domain is whitespace only 1`] = `
<div
data-__type="hrd_pane"
data-header={
<p>
Login with your corporate credentials. []
</p>
}
data-i18n={
{
"str": [Function],
}
}
data-model={
Immutable.Map {
"id": "__lock-id__",
"i18n": Immutable.Map {
"strings": Immutable.Map {
"enterpriseLoginIntructions": "Login with your corporate credentials.",
"enterpriseActiveLoginInstructions": "Please enter your corporate credentials at %s.",
},
},
}
}
data-passwordInputPlaceholder=" []"
data-usernameInputPlaceholder=" []"
/>
`;
37 changes: 37 additions & 0 deletions src/__tests__/connection/enterprise/hrd_screen.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,41 @@ describe('HRDScreen Component', () => {
const Component = getComponent();
expectComponent(<Component model={lock} i18n={i18nProp} />).toMatchSnapshot();
});

it('renders correctly when enterprise domain is undefined', () => {
require('connection/enterprise').enterpriseDomain.mockImplementation(() => undefined);
const Component = getComponent();
expectComponent(<Component model={lock} i18n={i18nProp} />).toMatchSnapshot();
});

it('does not show "undefined" in message when enterprise domain is undefined', () => {
require('connection/enterprise').enterpriseDomain.mockImplementation(() => undefined);
const { str } = i18nProp;

// Should use the fallback message without domain placeholder
const expectedMessage = str('enterpriseLoginIntructions');
expect(expectedMessage).toContain('Login with your corporate credentials.');
expect(expectedMessage).not.toContain('undefined');
});

it('does not show "undefined" in message when enterprise domain is null', () => {
require('connection/enterprise').enterpriseDomain.mockImplementation(() => null);
const { str } = i18nProp;
// Should use the fallback message without domain placeholder
const expectedMessage = str('enterpriseLoginIntructions');
expect(expectedMessage).toContain('Login with your corporate credentials.');
expect(expectedMessage).not.toContain('undefined');
});

it('uses fallback message when enterprise domain is empty string', () => {
require('connection/enterprise').enterpriseDomain.mockImplementation(() => '');
const Component = getComponent();
expectComponent(<Component model={lock} i18n={i18nProp} />).toMatchSnapshot();
});

it('uses fallback message when enterprise domain is whitespace only', () => {
require('connection/enterprise').enterpriseDomain.mockImplementation(() => ' ');
const Component = getComponent();
expectComponent(<Component model={lock} i18n={i18nProp} />).toMatchSnapshot();
});
});
2 changes: 1 addition & 1 deletion src/connection/enterprise/hrd_screen.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Component = ({ i18n, model }) => {

var headerText;

if (domain !== null) {
if (domain && domain.trim()) {
headerText = i18n.str('enterpriseActiveLoginInstructions', domain);
} else {
headerText = i18n.str('enterpriseLoginIntructions');
Expand Down