-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
162 additions
and
32 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
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 |
---|---|---|
@@ -1,9 +1,36 @@ | ||
/* eslint-disable import/order */ | ||
import { toYAML } from '../lib/serialize'; | ||
import { toYAML, obscureTemplate } from '../lib/serialize'; | ||
|
||
describe(toYAML, () => { | ||
test('does not wrap lines', () => { | ||
const longString = 'Long string is long!'.repeat(1_024); | ||
expect(toYAML({ longString })).toEqual(`longString: ${longString}\n`); | ||
}); | ||
}); | ||
|
||
describe(obscureTemplate, () => { | ||
test('removes CheckBootstrapVersion rule only', () => { | ||
const template = { | ||
Rules: { | ||
CheckBootstrapVersion: { Assertions: [{ AssertDescription: 'bootstrap' }] }, | ||
MyOtherRule: { Assertions: [{ AssertDescription: 'other' }] }, | ||
}, | ||
}; | ||
|
||
const obscured = obscureTemplate(template); | ||
expect(obscured).not.toHaveProperty('Rules.CheckBootstrapVersion'); | ||
expect(obscured).toHaveProperty('Rules.MyOtherRule.Assertions.0.AssertDescription', 'other'); | ||
}); | ||
|
||
test('removes all rules when CheckBootstrapVersion is the only rule', () => { | ||
const template = { | ||
Rules: { | ||
CheckBootstrapVersion: { Assertions: [{ AssertDescription: 'bootstrap' }] }, | ||
}, | ||
}; | ||
|
||
const obscured = obscureTemplate(template); | ||
expect(obscured).not.toHaveProperty('Rules.CheckBootstrapVersion'); | ||
expect(obscured).not.toHaveProperty('Rules'); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,17 +1,30 @@ | ||
import { AuthenticationError, ToolkitError } from '../lib/toolkit/error'; | ||
import { AssemblyError, AuthenticationError, ToolkitError } from '../lib/toolkit/error'; | ||
|
||
describe('toolkit error', () => { | ||
let toolkitError = new ToolkitError('Test toolkit error'); | ||
let authError = new AuthenticationError('Test authentication error'); | ||
let assemblyError = new AssemblyError('Test authentication error'); | ||
|
||
test('types are correctly assigned', async () => { | ||
expect(toolkitError.type).toBe('toolkit'); | ||
expect(authError.type).toBe('authentication'); | ||
expect(assemblyError.type).toBe('assembly'); | ||
}); | ||
|
||
test('isToolkitError and isAuthenticationError functions work', () => { | ||
test('isToolkitError works', () => { | ||
expect(ToolkitError.isToolkitError(toolkitError)).toBe(true); | ||
expect(ToolkitError.isToolkitError(authError)).toBe(true); | ||
expect(ToolkitError.isToolkitError(assemblyError)).toBe(true); | ||
}); | ||
|
||
test('isAuthenticationError works', () => { | ||
expect(ToolkitError.isAuthenticationError(toolkitError)).toBe(false); | ||
expect(ToolkitError.isAuthenticationError(authError)).toBe(true); | ||
}); | ||
|
||
test('isAssemblyError works', () => { | ||
expect(ToolkitError.isAssemblyError(assemblyError)).toBe(true); | ||
expect(ToolkitError.isAssemblyError(toolkitError)).toBe(false); | ||
expect(ToolkitError.isAssemblyError(authError)).toBe(false); | ||
}); | ||
}); |
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