Skip to content

Commit

Permalink
fix: avoid the impact of line breaks CRLF in frontend.test.ts (#420)
Browse files Browse the repository at this point in the history
* fix: avoid the impact of line breaks CRLF in frontend.test.ts

* fix: avoid the impact of line breaks CRLF in frontend.test.ts

* fix: avoid the impact of line breaks CRLF in frontend.test.ts
  • Loading branch information
imp2002 authored Feb 2, 2023
1 parent 5bfc390 commit 7c32e23
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/frontend.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ test('TestCasbinJsGetPermissionForUser', async () => {
throw new Error('Unexpected side affect.');
}
const received = JSON.parse(await casbinJsGetPermissionForUser(e, 'alice'));
const expectedModelStr = readFileSync('examples/rbac_model.conf').toString();
// If you enable CR_LF auto transfer on Windows platform, this can lead to some unexpected behavior.
let expectedModelStr = readFileSync('examples/rbac_model.conf').toString();

// avoid the impact of line breaks changing to CRLF, when automatic conversion is enabled
expectedModelStr = expectedModelStr.replace(/\r\n/g, '\n');

expect(received['m']).toBe(expectedModelStr.replace(/\n\n/g, '\n'));
const expectedPoliciesStr = readFileSync('examples/rbac_with_hierarchy_policy.csv').toString();

Expand Down

0 comments on commit 7c32e23

Please sign in to comment.