From 7c32e237a0881d74d8792e4ea7695999960e2e21 Mon Sep 17 00:00:00 2001 From: imp2002 Date: Thu, 2 Feb 2023 20:21:32 +0800 Subject: [PATCH] fix: avoid the impact of line breaks CRLF in frontend.test.ts (#420) * 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 --- test/frontend.test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/frontend.test.ts b/test/frontend.test.ts index acba9d8..315061f 100644 --- a/test/frontend.test.ts +++ b/test/frontend.test.ts @@ -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();