-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: parser not saving unlimited attempts (#483)
* fix: default settings not loading for new problems * fix: unlimited attempts not saving
- Loading branch information
1 parent
a959c05
commit e543ccc
Showing
10 changed files
with
114 additions
and
18 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
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
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,15 @@ | ||
import { snakeCase } from 'lodash-es'; | ||
|
||
const snakeCaseKeys = (obj) => { | ||
if (Array.isArray(obj)) { | ||
return obj.map(v => snakeCaseKeys(v)); | ||
} | ||
if (obj != null && obj.constructor === Object) { | ||
return Object.keys(obj).reduce( | ||
(result, key) => ({ ...result, [snakeCase(key)]: snakeCaseKeys(obj[key]) }), | ||
{}, | ||
); | ||
} | ||
return obj; | ||
}; | ||
export default snakeCaseKeys; |
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,32 @@ | ||
import { camelizeKeys } from './index'; | ||
|
||
const snakeCaseObject = { | ||
some_attribute: | ||
{ | ||
another_attribute: [ | ||
{ a_list: 'a lIsT' }, | ||
{ of_attributes: 'iN diFferent' }, | ||
{ different_cases: 'to Test' }, | ||
], | ||
}, | ||
a_final_attribute: null, | ||
a_last_one: undefined, | ||
}; | ||
const camelCaseObject = { | ||
someAttribute: | ||
{ | ||
anotherAttribute: [ | ||
{ aList: 'a lIsT' }, | ||
{ ofAttributes: 'iN diFferent' }, | ||
{ differentCases: 'to Test' }, | ||
], | ||
}, | ||
aFinalAttribute: null, | ||
aLastOne: undefined, | ||
}; | ||
|
||
describe('camelizeKeys', () => { | ||
it('converts keys of objects to be camelCase', () => { | ||
expect(camelizeKeys(snakeCaseObject)).toEqual(camelCaseObject); | ||
}); | ||
}); |