remove multiple lines fails #209

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

Projects

None yet

2 participants

@alexmasselot

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])
    })
})

})

@alexgraul
The Miso Project member

Ah, nice! Mind submitting a pull req?

@alexmasselot

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