-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #601 from namecheap/fix/NPF-3714-sdk-options-if-no…
…-i18n fix(SdkOptions): Fix SdkOptions to return cssBundle even if there no i18n asset
- Loading branch information
Showing
2 changed files
with
77 additions
and
5 deletions.
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,72 @@ | ||
const { expect } = require('chai'); | ||
const { SdkOptions } = require('./SdkOptions'); | ||
|
||
describe('SdkOptions Class', () => { | ||
it('should return i18n and cssBundle when both are provided', () => { | ||
const params = { | ||
i18n: { manifestPath: '/path/to/manifest' }, | ||
cssBundle: '/path/to/cssBundle', | ||
}; | ||
const sdkOptions = new SdkOptions(params); | ||
|
||
const result = sdkOptions.toJSON(); | ||
expect(result).to.deep.equal({ | ||
i18n: params.i18n, | ||
cssBundle: params.cssBundle, | ||
}); | ||
}); | ||
|
||
it('should return only i18n when cssBundle is not provided', () => { | ||
const params = { | ||
i18n: { manifestPath: '/path/to/manifest' }, | ||
}; | ||
const sdkOptions = new SdkOptions(params); | ||
|
||
const result = sdkOptions.toJSON(); | ||
expect(result).to.deep.equal({ | ||
i18n: params.i18n, | ||
cssBundle: undefined, | ||
}); | ||
}); | ||
|
||
it('should return only cssBundle when i18n is not provided', () => { | ||
const params = { | ||
cssBundle: '/path/to/cssBundle', | ||
}; | ||
const sdkOptions = new SdkOptions(params); | ||
|
||
const result = sdkOptions.toJSON(); | ||
expect(result).to.deep.equal({ | ||
i18n: undefined, | ||
cssBundle: params.cssBundle, | ||
}); | ||
}); | ||
|
||
it('should return undefined when no params are provided', () => { | ||
const sdkOptions = new SdkOptions(); | ||
|
||
const result = sdkOptions.toJSON(); | ||
expect(result).to.be.undefined; | ||
}); | ||
|
||
it('should return undefined when i18n does not have manifestPath and cssBundle is not provided', () => { | ||
const params = { | ||
i18n: {}, | ||
}; | ||
const sdkOptions = new SdkOptions(params); | ||
|
||
const result = sdkOptions.toJSON(); | ||
expect(result).to.be.undefined; | ||
}); | ||
|
||
it('should return undefined when both i18n and cssBundle are undefined', () => { | ||
const params = { | ||
i18n: undefined, | ||
cssBundle: undefined, | ||
}; | ||
const sdkOptions = new SdkOptions(params); | ||
|
||
const result = sdkOptions.toJSON(); | ||
expect(result).to.be.undefined; | ||
}); | ||
}); |