I have a file whose sole purpose is to provide an enormous collection of key/value pairs in an object. It looks something like this:
var myobj = {
some_key: 'some value',
another_key: 'another value',
// thousands of other key/value pairs...
some_key: 'accidental duplicate key with different value'
};
Now when I reference that file and reference the some_key I get the accidental duplicate value because JavaScript will store the last declared key.
I want to write a unit test that checks this object for accidental duplicate keys. Problem is that JavaScript has already stripped out the duplicates. How would I accomplish this checking through unit tests?
(One answer would be to manually parse the file using string parsing to find the duplicates. This is brittle and I'd want to stay away from this.)