-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Jonas Lagoni <[email protected]>
- Loading branch information
1 parent
d4d7fc2
commit 86fa4ea
Showing
6 changed files
with
144 additions
and
7 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
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,64 @@ | ||
import { NavigationService } from '../navigation.service'; | ||
|
||
describe('NavigationService', () => { | ||
function updateLocation(search: string) { | ||
const location = { | ||
...window.location, | ||
search, | ||
}; | ||
Object.defineProperty(window, 'location', { | ||
writable: true, | ||
value: location, | ||
}); | ||
} | ||
|
||
describe('.isReadOnly', () => { | ||
test('should return false if reaOnly flag is not defined', () => { | ||
updateLocation('?url=some-url.json'); | ||
const result = NavigationService.isReadOnly(); | ||
expect(result).toEqual(false); | ||
}); | ||
|
||
test('should return true if reaOnly flag is defined - empty value case', () => { | ||
updateLocation('?readOnly'); | ||
const result = NavigationService.isReadOnly(); | ||
expect(result).toEqual(true); | ||
}); | ||
|
||
test('should return true if reaOnly flag is defined - true value case', () => { | ||
updateLocation('?readOnly=true'); | ||
const result = NavigationService.isReadOnly(); | ||
expect(result).toEqual(true); | ||
}); | ||
|
||
test('should return false if reaOnly flag is not defined - non empty/true value case', () => { | ||
updateLocation('?readOnly=false'); | ||
const result = NavigationService.isReadOnly(); | ||
expect(result).toEqual(false); | ||
}); | ||
|
||
test('should return false if reaOnly flag is not defined - strict mode case without other parameters', () => { | ||
updateLocation('?readOnly=true'); | ||
const result = NavigationService.isReadOnly(true); | ||
expect(result).toEqual(false); | ||
}); | ||
|
||
test('should return true if reaOnly flag is not defined - strict mode case with url parameter', () => { | ||
updateLocation('?readOnly=true&url=some-url.json'); | ||
const result = NavigationService.isReadOnly(true); | ||
expect(result).toEqual(true); | ||
}); | ||
|
||
test('should return true if reaOnly flag is not defined - strict mode case with load parameter', () => { | ||
updateLocation('?readOnly=true&load=some-url.json'); | ||
const result = NavigationService.isReadOnly(true); | ||
expect(result).toEqual(true); | ||
}); | ||
|
||
test('should return true if reaOnly flag is not defined - strict mode case with base64 parameter', () => { | ||
updateLocation('?readOnly=true&base64=AsyncAPI'); | ||
const result = NavigationService.isReadOnly(true); | ||
expect(result).toEqual(true); | ||
}); | ||
}); | ||
}); |
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