Skip to content

Commit

Permalink
fix: avoid the impact of line breaks CRLF in frontend.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
imp2002 committed Feb 2, 2023
1 parent 5bfc390 commit a03fb33
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/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 a03fb33

Please sign in to comment.