Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove multiple lines fails #209

Open
alexmasselot opened this issue Sep 2, 2013 · 3 comments
Open

remove multiple lines fails #209

alexmasselot opened this issue Sep 2, 2013 · 3 comments

Comments

@alexmasselot
Copy link

Hi
trying to remove multiple lines fail with version 0.4.1
Her is the fix, line 1243 of miso.ds.0.4.1.m.js

_.each(rowsToRemove, function(rowId) {
is rewritten
_.each(rowsToRemove.reverse(), function(rowId) {
That's a classic one, nope?

Want a jasmine test?? see below, the two last tests are failing by removing the wrong line...

Thanks a lot for for the Miso works ;)

define(['underscore', 'Miso'], function(_, Miso) {
describe('Miso.Dataset', function() {
//just make a array of element with incremental id fireld and one char at a time
var buildDummy = function(chars) {
return _.map(chars.split(''), function(c, i) {
return {
idx : i,
val : c
}
})
}
// load a dummy dataset and exeut the callback test when fetched
var checkWithDummyDS = function(testName, chars, testCallback) {
it(testName, function() {
var ds = new Miso.Dataset({
data : buildDummy(chars)
});
var ok;
ds.fetch({
success : function() {
ok = true
},
error : function(err) {
throw err
}
})
waitsFor(function() {
return ok
})
runs(function() {
testCallback(ds)
})
})
}
it('builDummy', function() {
expect(buildDummy('acc')).toEqual([{
idx : 0,
val : 'a'
}, {
idx : 1,
val : 'c'
}, {
idx : 2,
val : 'c'
}]);

    })
    checkWithDummyDS('size', 'abcdefg', function(ds) {
        expect(ds.length).toBe(7)
    })

  checkWithDummyDS('remove one "b"', 'aabccdd', function(ds) {
        expect(ds.column('idx').data).toEqual([0, 1, 2, 3, 4, 5, 6])
        expect(ds.column('val').data).toEqual(['a', 'a', 'b', 'c', 'c', 'd', 'd'])
        console.log('remove')
        ds.remove(function(row) {
            return row.val == 'b'
        });
        expect(ds.length).toBe(6)
        expect(ds.column('val').data).toEqual(['a', 'a', 'c', 'c', 'd', 'd'])
        expect(ds.column('idx').data).toEqual([0, 1, 3, 4, 5, 6])
    })
    checkWithDummyDS('remove multiple alternated "b"', 'aabcbcdd', function(ds) {
        expect(ds.column('idx').data).toEqual([0, 1, 2, 3, 4, 5, 6, 7])
        expect(ds.column('val').data).toEqual(['a', 'a', 'b', 'c', 'b', 'c', 'd', 'd'])
        ds.remove(function(row) {
            return row.val == 'b'
        });
        expect(ds.length).toBe(6)
        expect(ds.column('val').data).toEqual(['a', 'a', 'c', 'c', 'd', 'd'])
        expect(ds.column('idx').data).toEqual([0, 1, 3, 5, 6, 7])
    })

    checkWithDummyDS('remove multiple successive "b"', 'aabbccdd', function(ds) {
        expect(ds.column('idx').data).toEqual([0, 1, 2, 3, 4, 5, 6, 7])
        expect(ds.column('val').data).toEqual(['a', 'a', 'b', 'b', 'c', 'c', 'd', 'd'])
        ds.remove(function(row) {
            return row.val == 'b'
        });
        expect(ds.length).toBe(6)
        expect(ds.column('val').data).toEqual(['a', 'a', 'c', 'c', 'd', 'd'])
        expect(ds.column('idx').data).toEqual([0, 1, 4, 5, 6, 7])
    })
})

})

@alexmasselot
Copy link
Author

solved in fork https://github.com/alexmasselot/dataset

@alexgraul
Copy link
Member

Ah, nice! Mind submitting a pull req?

@alexmasselot
Copy link
Author

done.
That hardest part was to discover how github works for contributions (OK, I'm ashamed of discovering that only now....)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants