-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ui/uiApp] add tests to verify #getModules() sorts modules
- Loading branch information
Showing
3 changed files
with
128 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import sinon from 'sinon'; | ||
import expect from 'expect.js'; | ||
|
||
import { appEntryTemplate } from '../app_entry_template'; | ||
|
||
function createMockBundle() { | ||
return { | ||
getContext: sinon.stub().returns(''), | ||
getRequires: sinon.stub().returns([]) | ||
}; | ||
} | ||
|
||
describe('ui bundles / appEntryTemplate', () => { | ||
it('embeds bundle.getContext() result', () => { | ||
const bundle = createMockBundle(); | ||
bundle.getContext.returns('foo bar baz'); | ||
expect(appEntryTemplate(bundle)).to.contain('foo bar baz'); | ||
}); | ||
|
||
it('joins requires into list', () => { | ||
const bundle = createMockBundle(); | ||
const requires = [ | ||
'foo', | ||
'bar', | ||
'baz' | ||
]; | ||
bundle.getRequires.returns(requires); | ||
expect(appEntryTemplate(bundle)).to.contain(requires.join('\n')); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import expect from 'expect.js'; | ||
|
||
import { UiBundle } from '../ui_bundle'; | ||
|
||
describe('ui bundles / UiBundle', () => { | ||
describe('#getRequires', () => { | ||
it('returns modules option as a list of require calls', () => { | ||
const bundle = new UiBundle({ | ||
modules: [ | ||
'a', | ||
'b', | ||
'c' | ||
] | ||
}); | ||
|
||
expect(bundle.getRequires()).to.eql([ | ||
`require('a');`, | ||
`require('b');`, | ||
`require('c');`, | ||
]); | ||
}); | ||
|
||
it('does not sort modules', () => { | ||
const bundle = new UiBundle({ | ||
modules: [ | ||
'c', | ||
'a', | ||
'b' | ||
] | ||
}); | ||
|
||
expect(bundle.getRequires()).to.eql([ | ||
`require('c');`, | ||
`require('a');`, | ||
`require('b');`, | ||
]); | ||
}); | ||
|
||
it('converts \\ to /', () => { | ||
const bundle = new UiBundle({ | ||
modules: [ | ||
'a\\b\\c', | ||
'd/e/f', | ||
] | ||
}); | ||
|
||
expect(bundle.getRequires()).to.eql([ | ||
`require('a/b/c');`, | ||
`require('d/e/f');`, | ||
]); | ||
}); | ||
}); | ||
}); |