generated from companieshouse/node-review-web-starter-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #599 from companieshouse/IDVA5-1719-lang-switch-bug
Add lang to payment return uri, remove lang select on confirmation view
- Loading branch information
Showing
9 changed files
with
71 additions
and
12 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
3 changes: 3 additions & 0 deletions
3
src/views/common/application-confirmation/application-confirmation.njk
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 |
---|---|---|
|
@@ -10,5 +10,8 @@ export const mockRequest = () => { | |
req.params = { | ||
id: "1" | ||
}; | ||
req.query = { | ||
lang: "en" | ||
}; | ||
return req; | ||
}; |
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,44 @@ | ||
import { addLangToUrl, selectLang } from "../../../src/utils/localise"; | ||
|
||
describe("selectLang", () => { | ||
it("should return 'cy' for 'cy'", () => { | ||
expect(selectLang("cy")).toBe("cy"); | ||
}); | ||
|
||
it("should return 'cy' for 'cy?lang=cy'", () => { | ||
expect(selectLang("cy?lang=cy")).toBe("cy"); | ||
}); | ||
|
||
it("should return 'en' for 'en'", () => { | ||
expect(selectLang("en")).toBe("en"); | ||
}); | ||
|
||
it("should return 'en' for 'en?lang=en'", () => { | ||
expect(selectLang("en?lang=en")).toBe("en"); | ||
}); | ||
|
||
it("should return 'en' for any other value", () => { | ||
expect(selectLang("fr")).toBe("en"); | ||
expect(selectLang("")).toBe("en"); | ||
expect(selectLang(null)).toBe("en"); | ||
expect(selectLang(undefined)).toBe("en"); | ||
}); | ||
}); | ||
|
||
describe("addLangToUrl", () => { | ||
it("should add lang parameter to URL without query string", () => { | ||
expect(addLangToUrl("http://example.com", "cy")).toBe("http://example.com?lang=cy"); | ||
}); | ||
|
||
it("should add lang parameter to URL with existing query string", () => { | ||
expect(addLangToUrl("http://example.com?param=value", "cy")).toBe("http://example.com?param=value&lang=cy"); | ||
}); | ||
|
||
it("should return the same URL if lang is undefined", () => { | ||
expect(addLangToUrl("http://example.com", undefined)).toBe("http://example.com"); | ||
}); | ||
|
||
it("should return the same URL if lang is an empty string", () => { | ||
expect(addLangToUrl("http://example.com", "")).toBe("http://example.com"); | ||
}); | ||
}); |