Skip to content

Commit

Permalink
NAS-128635 / 24.10 / Experimenting with immutability (#10008)
Browse files Browse the repository at this point in the history
  • Loading branch information
undsoft authored May 2, 2024
1 parent aadaf61 commit d6bfa60
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
"@types/glob": "~8.1.0",
"@types/inquirer": "^8.0.0",
"@types/js-yaml": "~4.0.8",
"@types/lodash": "4.14.195",
"@types/lodash": "4.17.0",
"@types/node": "~10.12.7",
"@types/pixi.js": "~4.7.1",
"@typescript-eslint/eslint-plugin": "~6.18.1",
Expand Down
14 changes: 10 additions & 4 deletions src/app/core/testing/classes/mock-websocket.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,14 @@ export class MockWebSocketService extends WebSocketService {

mockCall<K extends ApiCallMethod>(method: K, response: CallResponseOrFactory<K>): void {
const mockedImplementation = (_: K, params: ApiCallParams<K>): Observable<unknown> => {
let preparedResponse = response;
if (response instanceof Function) {
return of(response(params));
preparedResponse = response(params);
}

return of(response);
Object.freeze(preparedResponse);

return of(preparedResponse);
};

when(this.call).calledWith(method).mockImplementation(mockedImplementation);
Expand Down Expand Up @@ -107,10 +110,13 @@ export class MockWebSocketService extends WebSocketService {
job = response;
}

return {
job = {
...job,
id: this.jobIdCounter,
} as Job<ApiJobResponse<M>>;
};

Object.freeze(job);
return job as Job<ApiJobResponse<M>>;
};
when(this.startJob).calledWith(method).mockReturnValue(of(this.jobIdCounter));
when(this.startJob).calledWith(method, anyArgument).mockReturnValue(of(this.jobIdCounter));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class PrivilegeFormComponent implements OnInit {

readonly rolesOptions$ = this.ws.call('privilege.roles').pipe(
map((roles) => {
const sortedRoles = roles.sort((a, b) => {
const sortedRoles = roles.toSorted((a, b) => {
// Show compound roles first, then sort by name.
if (a.builtin === b.builtin) {
return a.name.localeCompare(b.name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ export class ChartWizardComponent implements OnInit, OnDestroy {
.pipe(this.loader.withLoader(), untilDestroyed(this))
.subscribe({
next: (app) => {
app.schema = app.versions[app.latest_version].schema;
this.setChartForCreation(app);
this.setChartForCreation({
...app,
schema: app.versions[app.latest_version].schema,
});
this.afterAppLoaded();
},
error: (error: WebSocketError) => this.afterAppLoadError(error),
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"target": "ES2022",
"allowSyntheticDefaultImports": true,
"lib": [
"es2020",
"es2023",
"dom",
"dom.Iterable"
],
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4606,10 +4606,10 @@
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==

"@types/lodash@4.14.195":
version "4.14.195"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.195.tgz#bafc975b252eb6cea78882ce8a7b6bf22a6de632"
integrity sha512-Hwx9EUgdwf2GLarOjQp5ZH8ZmblzcbTBC2wtQWNKARBSxM9ezRIAUpeDTgoQRAFB0+8CNWXVA9+MaSOzOF3nPg==
"@types/lodash@4.17.0":
version "4.17.0"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.17.0.tgz#d774355e41f372d5350a4d0714abb48194a489c3"
integrity sha512-t7dhREVv6dbNj0q17X12j7yDG4bD/DHYX7o5/DbDxobP0HnGPgpRz2Ej77aL7TZT3DSw13fqUTj8J4mMnqa7WA==

"@types/marked@^4.3.0":
version "4.3.2"
Expand Down

0 comments on commit d6bfa60

Please sign in to comment.